﻿// -----------------------------------------------------------------------
// <copyright file="DocumentProcedureUIController.cs" company="Open Box Software">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

using System.Collections.Generic;
using ProcedureList.Library.Domain;
namespace SSMSProcedureList
{

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class DocumentProcedureUIController
    {
        private DocumentScanner _Scanner;
        private void Load(List<MethodDto> list, IEnumerable<TextContext> text, string name)
        {
            foreach (var item in text)
            {
                var dto = new MethodDto()
                   {
                       MethodName = item.Text,
                       ParentClassName = name,
                       Position = item.LineNumber
                   };
                list.Add(dto);
            }
        }

        public IList<MethodDto> GetMethods()
        {
            var list = new List<MethodDto>();

            Load(list, _Scanner.GetTempTables(), @"#TEMP");
            Load(list, _Scanner.GetRegions(), "#REGION");
            Load(list, _Scanner.GetVariables(), "@VARIABLE");
            Load(list, _Scanner.GetIndexes(), "IDX");

            return list;
        }

        public DocumentProcedureUIController(DocumentScanner scanner)
        {
            this._Scanner = scanner;
        }
    }
}
